<!doctype html>
<html>
 <head>
	<meta charset="UTF-8">
	<meta name="Generator" content="EditPlus®">
	<meta name="Author" content="">
	<meta name="Keywords" content="">
	<meta name="Description" content="">
	<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
	<meta name="renderer" content="webkit">
  <link rel="shortcut icon" type="image/x-icon" href="http://oydt3ttm3.bkt.clouddn.com/{{ $sate['icon'] }}">
	<title>{{ $sate['name'] }}</title>
	<link rel="stylesheet" type="text/css" href="{{ asset('css/base.css') }}">
  <link rel="stylesheet" type="text/css" href="{{ asset('css/login.css') }}">
	<link rel="stylesheet" type="text/css" href="{{ asset('btn.css') }}">
 </head>
 <body>

<!--- header begin-->
<header id="pc-header">
    <div class="login-header" style="padding-bottom:0">
        <div><h1><a href="index.html">
    			<a href="{{ route('Home.index') }}"><img src="http://oydt3ttm3.bkt.clouddn.com/{{ $sate['logo'] }}" style="width:190px"></a>
    		</a></h1></div>
    </div>
</header>
<!-- header End -->



<section id="login-content">
    <div class="login-centre">
        <div class="login-back">
            <div class="H-over">
                <form method="post" action="{{ route('home.doemailgetreturn') }}" class="form form-horizontal" id="form-addUser">
                  {{ csrf_field() }}

                    <center>
                        @if (session('message'))
                    		<div class="Huialert Huialert-error">
                    			<h3 style="color:red;margin-top:10px;">{{ session('message') }}</h3>
                    		</div>
                    		@endif
                        @if (count($errors) > 0)
                        <div class="Huialert Huialert-danger">
                          <ul>
                            @foreach ($errors->all() as $error)
                            <li><h3 style="color:red;margin-top:10px;">{{ $error }}</h3></li>
                            @endforeach
                          </ul>
                        </div>
                        @endif
                    </center>

                    <div class="login-input">
                        <label><i class="heart">*</i>绑定邮箱：</label>
                        @if (!empty($user))
                            <input type="text" class="list-input1" style="background:#ccc;" readonly unselectable="on" value="{{ $user['email'] }}" id="bindemail" name="bindemail">
                        @else
                            <input type="text" class="list-input1" id="bindemail" name="bindemail" placeholder="请输入您的邮箱号码">
                        @endif
                        <h3 id="bindemail-error" style="color:red;margin-top:10px;"></h3>
                    </div>

                    <div class="login-input">
                        <label><i class="heart">*</i>新密码：</label>
                        <input type="password" class="list-input" id="password" name="password" placeholder="">
                        <h3 id="password-error" style="color:red;margin-top:10px;"></h3>
                    </div>

                    <div class="login-input">
                        <label><i class="heart">*</i>请确认密码：</label>
                        <input type="password" class="list-input" id="password_confirmation" name="password_confirmation" placeholder="">
                        <h3 id="password_confirmation-error" style="color:red;margin-top:10px;"></h3>
                    </div>

                    <div class="login-input">
                        <label><i class="heart">*</i>邮箱验证码：</label>
                        <input type="text" class="list-iphone" id="emailcode" name="emailcode" placeholder="请填写邮箱验证码">
                        <i id="sendemailcode" style="margin-left:5px;background:#ccc;width:118px;margin-right:10px;" class="button button-action button-rounded">获取</i>
                        <h3 id="emailcode-error" style="color:red;margin-top:10px;"></h3>
                    </div>

                    <div style="margin-left:100px;">
                        <div class="login-button">
                            <input type="submit" id="submit"  style="width:280px;background:red;" value="确认修改" class="button button-highlight button-rounded button-large">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>

<!--- footer begin-->
<center>
<footer id="footer">
  <div class="w">
  	<div id="footer-2013">
  		<div class="aui-footer-bot">
  			<center>
  		    <ul class="time-lists aui-footer-pd clearfix" style="padding:50px;">
  		        <li class="aui-footer-list clearfix" style="padding-left:90px;width:120px;display:inline-block;">
  		            <h4>
  		                <span><img src="{{ asset('icon/icon-d1.png') }}"></span>
  		                <em>消费者权益</em>
  		            </h4>
  		        </li>
  		        <li class="aui-footer-list clearfix" style="padding-left:10px;width:120px;display:inline-block;">
  		            <h4>
  		                <span><img src="{{ asset('icon/icon-d2.png') }}"></span>
  		                <em>新手上路</em>
  		            </h4>
  		        </li>
  		        <li class="aui-footer-list clearfix" style="padding-left:10px;width:120px;display:inline-block;">
  		            <h4>
  		                <span><img src="{{ asset('icon/icon-d3.png') }}"></span>
  		                <em>保障正品</em>
  		            </h4>
  		        </li>
  		    </ul>
  			</center>
  		    <div style="border-bottom:1px solid #dedede"></div>
  		    <div class="time-lists aui-footer-pd time-lists-ls clearfix">

  		        <div class="aui-footer-list clearfix">
  		            <h4>友情链接</h4>
  		            <ul>
  		                @foreach ($linksArray as $linkArray)
  		                <li><a href="{{ $linkArray['url'] }}"> {{ $linkArray['name'] }} </a> </li>
  		                @endforeach
  		            </ul>
  		        </div>
  		    </div>
  		    <div class="time-lists aui-footer-pd time-lists-ls clearfix">
            <p><h3 style="width:1200px;text-align: center">{{ $sate['desc'] }}</h3></p>
            <p><h3 style="width:1200px;text-align: center">{{ $sate['message'] }}</h3></p>
            <p><h3 style="width:1200px;text-align: center">{{ $sate['record'] }}</h3></p>
  		    </div>
  		</div>
  	</div>
  </div>
</footer>
</center>
<!-- footer End -->
</body>
<script type="text/javascript" src="{{asset('AdminPublic/lib/jquery/1.9.1/jquery.min.js')}}"></script>
<script type="text/javascript">
$('#sendemailcode').off('clikc');
number = 1;
sendstatus = 0;
captchacode = 0;


$('#bindemail').blur(function() {
    validataemail();
});

function validataemail(evn)
{
    $('#bindemail-error').html('');

    var bindemail = $('#bindemail').val();

    evn = evn || window.event;

    var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;

    if (bindemail == '') {
      $('#bindemail-error').html('邮箱不能为空');
      evn.preventDefault();
    }

    if (!reg.test(bindemail)) {
      $('#bindemail-error').html('邮箱格式不正确，请重新输入');
      evn.preventDefault();
      return false;
    }

    $.ajax({
        type: 'post',
        url: "{{ route('home.validataemail') }}",
        data: "bindemail="+ bindemail +"&_token={{ csrf_token() }}",
        dataType: 'JSON',
        success:function(data)
        {
            console.log(data);
            $('#phonecode-error').html('');

            @if (empty($user))
                if (data == 2) {
                    $('#bindemail-error').html('');
                    $('#bindemail-error').html('该邮箱未绑定，请重新填写');
                    return false;
                }
            @else
                if (data == 2) {
                    $('#bindemail-error').html('');
                    $('#bindemail-error').html('服务器内部错误，请刷新页面');
                    return false;
                }
            @endif
      }
    });
}

// 判断密码
$('#password').blur(function() {

    var password = $('#password').val();
    $('#password-error').html('');


    if (password == '') {
        $('#password-error').html('');
        $('#password-error').html('密码不能为空');
        return false;
    }

    if (password.length < 6) {
        $('#password-error').html('');
        $('#password-error').html('密码不能少于6个字符');
        return false;
    }

    if (password.length > 100) {
        $('#password-error').html('');
        $('#password-error').html('密码不能多于100个字符');
        return false;
    }

    $('#password-error').html('');

});

// 判断确认密码
$('#password_confirmation').blur(function() {

    var password_confirmation = $('#password_confirmation').val();
    var password = $('#password').val();
    var bindemail = $('#bindemail').val();

    $('#password_confirmation-error').html('');

    if (password_confirmation !== password) {
        $('#password_confirmation-error').html('');
        $('#password_confirmation-error').html('两次密码不相同');
        return false;
    }

    if (password_confirmation == '') {
        $('#password_confirmation-error').html('');
        $('#password_confirmation-error').html('确认密码不能为空');
        return false;
    }

    validataemail();

    $('#sendemailcode').click(function() {
        if (number > 1) {
            return false;
        }
        number++;
        $.ajax({
            type: 'post',
            url: "{{ route('home.emailcode') }}",
            data: "bindemail=" + bindemail + "&_token={{ csrf_token() }}",
            dataType: 'JSON',
            success:function(data)
            {
                if (data == 403) {
                  number = 1;
                  $('#emailcode-error').html('');
                  $("#emailcode-error").html('120秒内只能获取一次！');
                  return false;
                }

                $('#emailcode-error').html('');

                var time = 120;

                var marke = setInterval(function() {

                    time--;
                    console.log(1);
                    $("#sendemailcode").html('(' +  time + ')');

                    if (time < 1) {
                        clearInterval(marke);
                        number = 1;
                        $("#sendemailcode").html('获取');
                    }

                }, 1000);
                $('#emailcode-error').html('');
            }
        });
        $('#emailcode-error').html('');

    });

    $('#password_confirmation-error').html('');

});

$('#emailcode').blur(function() {

    var emailcode = $('#emailcode').val();
    var bindemail = $('#bindemail').val();

    $.ajax({
        type: 'post',
        url: "{{ route('home.valicode') }}",
        data: "bindemail=" + bindemail + "&code=" + emailcode + "&_token={{ csrf_token() }}",
        dataType: 'JSON',
        success:function(data)
        {
            captchacode = data;
        }
    });

})

$("#submit").click(function(evn) {

    evn = evn || window.event;

    var bindemail = $('#bindemail').val();
    var emailcode = $('#emailcode').val();
    var password = $('#password').val();
    var password_confirmation = $('#password_confirmation').val();

    $("#bindemail-error").html('');
    $('#emailcode-error').html('');
    $('password-error').html('');
    $('#password_confirmation-error').html('');

    if (password == '') {
        $('#password-error').html('');
        $('#password-error').html('密码不能为空');
        return false;
    }

    if (password.length < 6) {
        $('#password-error').html('');
        $('#password-error').html('密码不能少于6个字符');
        return false;
    }

    if (password.length > 100) {
        $('#password-error').html('');
        $('#password-error').html('密码不能多于100个字符');
        return false;
    }

    if (password_confirmation !== password) {
        $('#password_confirmation-error').html('');
        $('#password_confirmation-error').html('两次密码不相同');
        return false;
    }

    if (password_confirmation == '') {
        $('#password_confirmation-error').html('');
        $('#password_confirmation-error').html('确认密码不能为空');
        return false;
    }


    var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
    if (bindemail == '') {
        $('#bindemail-error').html('');
        $('#bindemail-error').html('邮箱不能为空');
        evn.preventDefault();
    }

    if (!reg.test(bindemail)) {
        $('#bindemail-error').html('');
        $('#bindemail-error').html('邮箱格式不正确，请重新输入');
        evn.preventDefault();
        return false;
    }


    if (emailcode == '') {
        $('#emailcode-error').html('');
        $('#emailcode-error').html('验证码不能为空');
        evn.preventDefault();
        return false;
    }

    if (emailcode.length < 6) {
        $('#emailcode-error').html('验证码不能少于六位');
        evn.preventDefault();
        return false;
        $('#emailcode-error').html('');
    }

    if (emailcode.length > 6) {
        $('#emailcode-error').html('');
        $('#emailcode-error').html('验证码不能多于六位');
        evn.preventDefault();
        return false;
    }


    if (captchacode == "403") {
        $('#emailcode-error').html('');
        $('#emailcode-error').html('验证码已过期');
        evn.preventDefault();
        return false;
    }

    if (captchacode == "500") {
        $('#emailcode-error').html('');
        $('#emailcode-error').html('验证码不正确');
        evn.preventDefault();
        return false;
    }

    if (captchacode == 0) {
        $('#emailcode-error').html('');
        $('#emailcode-error').html('验证码不正确');
        evn.preventDefault();
        return false;
    }

});




</script>
</html>
